use compare_string::compare_string::{string_compare, string_equal, string_nocase_compare, string_nocase_equal};

#[test]
fn test_string_compare() {
    let test1 = "Apple";
    let test2 = "Orange";
    let test3 = "Apple";

    // Negative if first argument should be sorted before the second
    assert!(string_compare(test1, test2) < 0);

    // Positive if the second argument should be sorted before the first
    assert!(string_compare(test2, test1) > 0);

    // Zero if the two arguments are equal
    assert!(string_compare(test1, test3) == 0);
}

#[test]
fn test_string_equal() {
    let test1 = "this is a test string";
    let test2 = "this is a test string ";
    let test3 = "this is a test strin";
    let test4 = "this is a test strinG";
    let test5 = "this is a test string";

    // Non-zero (true) if the two strings are equal
    assert!(string_equal(test1, test5));

    // Zero (false) if the two strings are different
    // Check that length affects the result
    assert!(!string_equal(test1, test2));
    assert!(!string_equal(test1, test3));

    // Case sensitive
    assert!(!string_equal(test1, test4));
}

#[test]
fn test_string_nocase_compare() {
    let test1 = "Apple";
    let test2 = "Orange";
    let test3 = "Apple";
    let test4 = "Alpha";
    let test5 = "bravo";
    let test6 = "Charlie";

    // Negative if first argument should be sorted before the second
    assert!(string_nocase_compare(test1, test2) < 0);

    // Positive if the second argument should be sorted before the first
    assert!(string_nocase_compare(test2, test1) > 0);

    // Zero if the two arguments are equal
    assert!(string_nocase_compare(test1, test3) == 0);

    // Check ordering is independent of case
    assert!(string_nocase_compare(test4, test5) < 0);
    assert!(string_nocase_compare(test5, test6) < 0);
}

#[test]
fn test_string_nocase_equal() {
    let test1 = "this is a test string";
    let test2 = "this is a test string ";
    let test3 = "this is a test strin";
    let test4 = "this is a test strinG";
    let test5 = "this is a test string";

    // Non-zero (true) if the two strings are equal
    assert!(string_nocase_equal(test1, test5));

    // Zero (false) if the two strings are different
    // Check that length affects the result
    assert!(!string_nocase_equal(test1, test2));
    assert!(!string_nocase_equal(test1, test3));

    // Case insensitive
    assert!(string_nocase_equal(test1, test4));
}